package com.ruoyi.system.enumeration;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * 库存预警状态枚举
 */

@Getter
@AllArgsConstructor
public enum StockWarningEnum {

    NORMAL(0, "正常"),
    LOW_STOCK(1, "库存下限报警"),
    HIGH_STOCK(2, "库存上限报警");

    private final Integer key;
    private final String value;

    // 缓存 key -> value 映射，提高查询效率
    private static final Map<Integer, String> ENUM_MAP = new HashMap<>();

    static {
        for (StockWarningEnum item : StockWarningEnum.values()) {
            ENUM_MAP.put(item.getKey(), item.getValue());
        }
    }

    /**
     * 根据 key 获取 value（描述）
     *
     * @param key 枚举键
     * @return 描述信息
     */
    public static String getValueByKey(Integer key) {
        return ENUM_MAP.getOrDefault(key, "未知");
    }

}
